class SessionsController < ApplicationController
  def new
  end

  def create
  @user = User.find(:first, :conditions => ['login = ? AND password = ?', params[:login],params[:password]])
  if @user
    session[:logged] = true
    session[:username] = @user.login
    session[:tipo] = @user.tipo
    redirect_to livros_path
  else 
    @erro = '* Usuario nao encontrado'
    render :action => 'new'
  end
  end

  def destroy
  session[:logged] = false
  render :action => 'new'
  end

end
